Pearson Edexcel · GCSE · Computer Science

    Course version: 1CP2 · Version from Sept 2020

    Understand how an interpreter differs from a compiler in the way it…

    Full specification wording

    Programming languages: 3.3.2 understand how an interpreter differs from a compiler in the way it translates high-level code into machine code

    A compiler translates the whole high-level source program in one go, producing a machine code file that can then be run without the compiler present.

    Checked against the Pearson Edexcel 1CP2 specification (opens in a new tab) on .

    • Point 2 of 2
    • 4 key terms

    Study notes

    From the checked teaching notes for this specification point.

    The idea

    A compiler translates the whole high-level source program in one go, producing a machine code file that can then be run without the compiler present. Errors are reported together after translation, and the compiled program usually runs quickly because translation has already happened. An interpreter translates and executes the source one statement at a time, so it stops at the first error it meets and no separate machine code file is produced; the interpreter must be present each time the program runs. Interpretation suits development and testing because errors are found immediately, while compilation suits finished software that must run efficiently and be distributed without source code.

    What earns the marks

    • A compiler translates the entire source program before any of it is executed, producing a machine code file.
    • A compiler reports errors together after translating the whole program, so several errors may be listed at once.
    • An interpreter translates and executes one statement at a time, stopping when it reaches an error.
    • An interpreter does not produce a standalone machine code file, so the interpreter must be available whenever the program runs.
    • Compiled code generally executes faster because translation is completed in advance; interpreted code is convenient during development because errors appear immediately.
    • The choice depends on purpose: interpretation for testing and learning, compilation for efficient distribution of finished software.

    Common mistakes and how to put them right

    • Saying an interpreter translates the whole program first.

      Put it right: It works statement by statement, executing as it goes.

    • Claiming a compiler runs the program.

      Put it right: The compiler produces machine code, and the resulting file is what runs.

    • Thinking interpreted programs never become machine code.

      Put it right: Each statement is translated into machine code as it is reached, but no complete machine code file is saved.

    • Believing only compilers find errors.

      Put it right: Both find errors, but a compiler reports them after translating everything, while an interpreter stops at the first error encountered.

    Exam tips

    • Answer with the translation unit: whole program for a compiler, one statement at a time for an interpreter.
    • Mention the output: a compiler produces a machine code file, an interpreter does not.
    • Add the practical consequence, such as speed of the finished program or immediate error reporting, to secure the explanation mark.

    Try the lesson

    The start of the Programming languages: 3.3.2 understand how an interpreter differs from a compiler in the way it translates high-level code into machine code lesson, made from checked teaching notes for this specification point.

    Have a go first

    An interpreter is used to run a high-level program. How does the interpreter translate the high-level code into machine code?

    Listen

    A compiler translates the whole high-level source program in one go, producing a machine code file that can then be run without the compiler present. Errors are reported together after translation, and the compiled program usually runs quickly because translation has already happened. An interpreter translates and executes the source one statement at a time, so it stops at the first error it meets and no separate machine code file is produced; the interpreter must be present each time the program runs. Interpretation suits development and testing because errors are found immediately, while compilation suits finished software that must run efficiently and be distributed without source code. A strong answer earns marks for these points. A compiler translates the entire source program before any of it is executed, producing a machine code file. A compiler reports errors together after translating the whole program, so several errors may be listed at once. An interpreter translates and executes one statement at a time, stopping when it reaches an error. An interpreter does not produce a standalone machine code file, so the interpreter must be available whenever the program runs. Exam tip: Answer with the translation unit: whole program for a compiler, one statement at a time for an interpreter.

    See it

    A flowchart starting from a single node, high-level source code, which branches into two paths. The left path goes to a compiler, which translates the whole program in one go; this leads to a machine code file being produced, the file running without the compiler present, and errors being reported together after translation. The right path goes to an interpreter, which translates and executes one statement at a time; this leads to stopping at the first error it meets, no separate machine code file being produced, and the interpreter having to be present each time the program runs.
    It shows how a compiler and an interpreter each translate high-level source code, and the different results of each approach.

    Key words

    Say what each word means before you turn the card.

    Compiler behaviour

    Try answering aloud or in your head before turning the card.

    Interpreter behaviour

    Try answering aloud or in your head before turning the card.

    Errors and execution speed

    Try answering aloud or in your head before turning the card.

    Translation of high-level code

    Try answering aloud or in your head before turning the card.

    See every definition
    Compiler behaviour
    Translates the entire source program before any of it is executed, producing a machine code file, and reports errors together after translating the whole program.
    Interpreter behaviour
    Translates and executes the source one statement at a time, stopping when it reaches an error, and produces no standalone machine code file.
    Errors and execution speed
    Compiled code generally executes faster because translation is completed in advance, while interpreted code is convenient during development because errors appear immediately.
    Translation of high-level code
    A compiler translates the whole high-level source program in one go, whereas an interpreter translates and executes it one statement at a time.

    Label the diagram

    Some boxes have lost their names. Pick the right name for each number.

    The diagram again, with 3 boxes numbered instead of named. A flowchart starting from a single node, high-level source code, which branches into two paths. The left path goes to a compiler, which translates the whole program in one go; this leads to a machine code file being produced, the file running without the compiler present, and errors being reported together after translation. The right path goes to an interpreter, which translates and executes one statement at a time; this leads to stopping at the first error it meets, no separate machine code file being produced, and the interpreter having to be present each time the program runs.
    • 1Box 1

    • 2Box 2

    • 3Box 3

    0 of 3 labelled

    There is more to this lesson

    The full lesson goes on to check your understanding and help you earn the marks. Create a free account to carry on, with your progress saved.

    Carry on with the full lesson

    A week of Premium from your first lesson · Then the free plan continues · No card, no charge

    Test your understanding of Programming languages: 3.3.2 understand how an interpreter differs from a compiler in the way it translates high-level code into machine code

    Active recall beats re-reading. Take an instant quiz now to test what you’ve learned and lock it into long-term memory.

    Take topic quiz

    A week of Premium from your first lesson · Then the free plan continues · No card, no charge